<extend name="Base/common"/>

<block name="body">

    <div id="BeTeature">

        <header>

            <a href="__MODULE__/Index/index" class="back"><img src="__IMG__/images/back_03.png"/></a><?php echo $intro;?>

            <neq name="pause" value="1">

            <eq name="Think.get.teaching" value="2">

            <a href="javascript:;" class="sure"><eq name="end_teach" value="1">信息上架<else/>信息下架</eq></a>

            <else/>

            <a href="javascript:;" class="sure"><eq name="end_study" value="1">信息上架<else/>信息下架</eq></a>

            </eq>

            </neq>

        </header>

        <form action="__SELF__"  class="form-horizontal"  method="post" enctype="multipart/form-data" id="mac">

            <div class="BeTeature">

                <ul>

                    <li>

                        <h1><img src="__IMG__/images/headLine_07.jpg"/><?php if($_GET['teaching'] == 2){?>教学内容<?php }else{?>学习内容<?php }?><a href="__CONTROLLER__/mycourses/teaching/{$Think.get.teaching}"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>

                    <volist name="courses" id="c">

                        <p class="piano">

                            <span class="f-fl">{$c.title}</span><span class="f-fr" style="margin-right: 1.2rem">{$c.salary}元/小时</span>

                        <div class="clear"></div>

                        </p>

                        <p class="piano1">{$c.content}</p>

                    </volist>

                    </li>

                    <li>

                        <h1><img src="__IMG__/images/headLine_07.jpg"/>一句话简介 <a href="javascript:;" class="inaword"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>

                        <p class="piano1">{$introduce.inaword}</p>

                        <div class="area" style="display: none;"><textarea name="inaword" class="inaword">{$introduce.inaword}</textarea></div>

                    </li>

                    <li>

                        <h1><img src="__IMG__/images/headLine_07.jpg"/>自我介绍 <a href="javascript:;" class="introduce"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>

                        <p class="piano1">{$introduce.introduce}</p>

                        <div class="area" style="display: none;"><textarea name="introduce" class="introduce">{$introduce.introduce}</textarea></div>

                    </li>

                    <if condition="$_GET['teaching'] eq 2">

                    <li>

                        <h1><img src="__IMG__/images/headLine_07.jpg"/>微信二维码 </h1>

                        <p class="piano1"></p>

                        <div class="area">      

                            <img id="pic"  src="<if condition="$pics neq ''">__ROOT__{$pics|getimg=###}<else/>__IMG__/images/scewm_03.jpg</if>" alt="点击上传图片">

                            <!--<img id="pic" src="__IMG__/images/scewm_03.jpg" alt="点击上传图片">-->

                            <input id="upload" name="logo" accept="image/*" type="file" style="display: none"/>

                        </div>

                    </li>

                    </if>

                    <li>

                        <h1><img src="__IMG__/images/headLine_07.jpg"/>地区 <a href="javascript:;" class="introduce"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>

                        <p class="piano1">{$data.area_id|getParentArea=###}{$data.area_id|getArea=###}</p>

                        <div class="area" style="display: none;">

                            <select name="pid" id="aaaa">

                                <empty name="sheng">

                                    <option value="">请选择</option>

                                    <else/>

                                <option value="" class="aaaa">{$sheng.title}</option>

                                </empty>

                                <volist name="areas" id="v">

                                    <option value="{$v.id}">{$v.title}</option>

                                </volist>

                            </select>

                            <select name="area_id" class="class-area_id">

                               

                                <empty name="data.area_id" value="0">

                                    <option value="">请选择</option>

                                    <else/>

                                    <volist name="towArea" id="vol">

                                        <option value="{$vol.id}"<if condition="$vol['id'] eq $data['area_id']"> selected="selected"</if>>{$vol.title}</option>

                                    </volist>

                                </empty>

                            </select>

                        </div>

                    </li>
                </ul>
				<eq name="Think.get.teaching" value="2">
				<p style="margin-top:30px;color:orange;text-align:center;">上传正确的微信二维码，这样别人才可以联系到你。</p></eq>
                <p style="text-align: center;font-size: 24px;display:inline-block;padding-left:20px;"></p>

                <input type="hidden" name="id" value="{$introduce.id}">

                <input type="submit" id="btn" class="ajax-file " target-form="form-horizontal" value="提交" />

            </div>

        </form>

        <div class="stop"></div>

    </div>

    <style>

        .area{text-align: center;}

        .area .inaword{width: 40rem;height: 15rem;border-radius: 0.5rem;padding: 0.5rem;}

        .area .introduce{width: 40rem;height: 20rem;border-radius: 0.5rem;padding: 0.5rem;}

        #pic{width: 250px;margin: 20px auto;cursor: pointer;height: 250px;border: 1px solid; }

        #upload{border: none; }

    </style>



    <script type="text/javascript">

        $('#aaaa').click(function(){

            

        });

        //地区联动

        $('select[name=pid]').change(function () {

            

            $('.aaaa').remove();

//            $('select[name=area_id] option').remove();

            var id = $(this).val();

            $.post('__MODULE__/Area/areaList', {'id': id}, function (res) {

                $('.class-area_id').find('option').remove();

                $.each(res, function (index, el) {

                    $('select[name=area_id').append('<option value=\'' + el.id + '\'>' + el.title + '</option>');

                });

            });

        });

        //修改地区的

        $('.class-area_id').change(function () {

           var creaname = $('#aaaa').find('option:selected').html();

           var val = $(this).find('option:selected').html();

            $(this).parent().prev().replaceWith("<p class='piano1'>" + creaname+val + "</p>");

        });

        

        $(function () {

            $("#pic").click(function () {

                $("#upload").click();               //隐藏了input:file样式后，点击头像就可以本地上传

                $("#upload").on("change", function () {

                    var objUrl = getObjectURL(this.files[0]);  //获取图片的路径，该路径不是图片在本地的路径

                    if (objUrl) {

                        $("#pic").attr("src", objUrl);      //将图片路径存入src中，显示出图片

                    }

                });

            });

        });

        $(function () {

            var url = window.location.href;

            var msg = url.indexOf('msg', -1);

            if (msg != -1) {

                var data = "{$_GET['msg']}";

                data = data.substring(0, data.length - 1);

                data = data.substr(1, data.length);

                if (data != '') {

                    layer.alert(data);

                }

            }

        });

        //建立一個可存取到該file的url

        function getObjectURL(file) {

            var url = null;

            if (window.createObjectURL != undefined) { // basic

                url = window.createObjectURL(file);

            } else if (window.URL != undefined) { // mozilla(firefox)

                url = window.URL.createObjectURL(file);

            } else if (window.webkitURL != undefined) { // webkit or chrome

                url = window.webkitURL.createObjectURL(file);

            }

            return url;

        }

        $('.ajax-file').click(function () {

            var url = $('#mac').attr('action');

            var fd = new FormData($("#mac")[0]);

            $.ajax({

                url: url,

                type: "POST",

                data: fd,

                processData: false, // 告诉jQuery不要去处理发送的数据

                contentType: false, // 告诉jQuery不要去设置Content-Type请求

            });

        })

    </script>

    <script>

        //切换一句话介绍输入框

        $('.inaword').click(function () {

            tog($(this));

        });

        //切换自我介绍输入框

        $('.introduce').click(function () {

            tog($(this));

        });

        function tog(obj) {

            if (obj.parent().next('p').is(':hidden')) {

                obj.parent().next('p').show(200).next('div').slideUp(200);

                //修改显示的数据

                obj.parent().next('p').html(obj.parent().nextAll('div').find('textarea').val());

            } else {

                obj.parent().next('p').hide(200).next('div').slideDown(200).find('textarea').focus();

            }

        }



        //授课、学习状态切换

        $('.sure').click(function () {

            var val = $(this).html();

            var text;

            switch (val) {

                case '开始学习':

                case '信息上架':

                    text = '您是否要' + val + '，开始后您将重新在列表中展示。'

                    break;

                case '停止学习':

                case '信息下架':

                    text = '您是否要' + val + '，停止后您将不在列表中展示。'

                    break;

            }

            console.log(text);

            var teach = '{$Think.get.teaching}';

            if (teach == '1') {

                var column = 'end_study';

            } else if (teach == '2') {

                var column = 'end_teach';

            }

            layer.confirm(text, function (index) {

                $.post('__MODULE__/UserMember/endcourse', {column: column}, function (data) {

                    layer.close(index);

                    layer.msg(data, {time: 1500}, function () {

                        location.reload();

                    });

                });

            });

        });



    </script>

</block>